package com.tencent.stat.common;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;
import com.tencent.stat.StatConfig;
import java.util.Map;

public class StatPreferences
{
  private static SharedPreferences a = null;

  static SharedPreferences a(Context paramContext)
  {
    monitorenter;
    try
    {
      SharedPreferences localSharedPreferences;
      if (localSharedPreferences != null);
    }
    finally
    {
      try
      {
        if ((StatConfig.getMTAPreferencesFileName() == null) || (StatConfig.getMTAPreferencesFileName().trim().length() == 0))
        {
          a = PreferenceManager.getDefaultSharedPreferences(paramContext);
          paramContext = a;
          monitorexit;
          return paramContext;
        }
        a = paramContext.getSharedPreferences(StatConfig.getMTAPreferencesFileName(), 0);
      }
      catch (Exception paramContext)
      {
        while (true)
          paramContext.printStackTrace();
        paramContext = finally;
        monitorexit;
        throw paramContext;
      }
    }
  }

  public static boolean contains(Context paramContext, String paramString)
  {
    paramString = StatCommonHelper.getTagForConcurrentProcess(paramContext, paramString);
    return a(paramContext).contains(paramString);
  }

  public static Map getAll(Context paramContext)
  {
    return a(paramContext).getAll();
  }

  public static boolean getBoolean(Context paramContext, String paramString, boolean paramBoolean)
  {
    paramString = StatCommonHelper.getTagForConcurrentProcess(paramContext, paramString);
    return a(paramContext).getBoolean(paramString, paramBoolean);
  }

  public static float getFloat(Context paramContext, String paramString, float paramFloat)
  {
    paramString = StatCommonHelper.getTagForConcurrentProcess(paramContext, paramString);
    return a(paramContext).getFloat(paramString, paramFloat);
  }

  public static int getInt(Context paramContext, String paramString, int paramInt)
  {
    paramString = StatCommonHelper.getTagForConcurrentProcess(paramContext, paramString);
    return a(paramContext).getInt(paramString, paramInt);
  }

  public static long getLong(Context paramContext, String paramString, long paramLong)
  {
    paramString = StatCommonHelper.getTagForConcurrentProcess(paramContext, paramString);
    return a(paramContext).getLong(paramString, paramLong);
  }

  public static String getString(Context paramContext, String paramString1, String paramString2)
  {
    paramString1 = StatCommonHelper.getTagForConcurrentProcess(paramContext, paramString1);
    return a(paramContext).getString(paramString1, paramString2);
  }

  public static void putBoolean(Context paramContext, String paramString, boolean paramBoolean)
  {
    paramString = StatCommonHelper.getTagForConcurrentProcess(paramContext, paramString);
    paramContext = a(paramContext).edit();
    paramContext.putBoolean(paramString, paramBoolean);
    paramContext.commit();
  }

  public static void putFloat(Context paramContext, String paramString, float paramFloat)
  {
    paramString = StatCommonHelper.getTagForConcurrentProcess(paramContext, paramString);
    paramContext = a(paramContext).edit();
    paramContext.putFloat(paramString, paramFloat);
    paramContext.commit();
  }

  public static void putInt(Context paramContext, String paramString, int paramInt)
  {
    paramString = StatCommonHelper.getTagForConcurrentProcess(paramContext, paramString);
    paramContext = a(paramContext).edit();
    paramContext.putInt(paramString, paramInt);
    paramContext.commit();
  }

  public static void putLong(Context paramContext, String paramString, long paramLong)
  {
    paramString = StatCommonHelper.getTagForConcurrentProcess(paramContext, paramString);
    paramContext = a(paramContext).edit();
    paramContext.putLong(paramString, paramLong);
    paramContext.commit();
  }

  public static void putString(Context paramContext, String paramString1, String paramString2)
  {
    paramString1 = StatCommonHelper.getTagForConcurrentProcess(paramContext, paramString1);
    paramContext = a(paramContext).edit();
    paramContext.putString(paramString1, paramString2);
    paramContext.commit();
  }
}